package com.hj.dao;

import com.hj.model.Product;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author haoshen
 * @version 1.0
 */
@org.apache.ibatis.annotations.Mapper
@Repository
public interface ProductDao extends Mapper<Product> {
    /**
     * 找到每个类别最便宜的一个商品
     */
    @Select("SELECT id,category_id categoryId,name,detail,main_image mainImage,price,stock,status,create_time createTime,update_time updateTime FROM hj_product  p WHERE NOT EXISTS (select 1 from hj_product where category_id=p.category_id and price<p.price)")
    List<Product> selMinPrice();
}
